<template>
  <van-nav-bar title="消费记录" left-arrow fixed @click-left="onBack" />

  <div style="height: 46px"></div>

  <div class="list-box" v-if="OrderList.length > 0">
    <div class="list">
      <div class="item" v-for="item in OrderList" :key="item.id">
        <div v-for="son in item.OrderProduct">
          你购买了{{ son.products.name }} <br />
          购买金额：{{ son.price }} <br />
          购买时间：{{ item.createtime_text }}
          <hr />
        </div>
      </div>
    </div>
  </div>

  <van-empty description="暂无消费记录" v-else />
</template>

<script>
export default {
  data() {
    return {
      OrderList: [],
      LoginAuth: {},
    };
  },

  created() {
    this.LoginAuth = this.$cookies.get("LoginAuth")
      ? this.$cookies.get("LoginAuth")
      : {};

    this.getOrderData();
  },
  methods: {
    onBack() {
      this.$router.go(-1);
    },
    async getOrderData() {
      let data = {
        busid: this.LoginAuth.id,
      };

      if (this.active !== "") {
        data.status = this.active;
      }

      let result = await this.$api.OrderIndex(data);

      if (result.code === 1) {
        this.OrderList = result.data;
      }
    },
  },
};
</script>

<style scoped>
</style>